package jdbc;


import BusinessLayer.Departement;
import PersistanceLayer.AbstractDAOFactory;
import PersistanceLayer.DAO;
import PersistanceLayer.DepartementDAO;

import java.sql.Connection;
import java.sql.DriverManager;
//import java.sql.ResultSet;
//import java.sql.ResultSetMetaData;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
//import java.sql.Statement;


public class ConnectionToOracle{

	/**
	 * URL de connection
	 */
	private static String url = "jdbc:oracle:thin:v240.ig.polytech.univ-montp2.fr:1521:ORA10";
	/**
	 * Nom du user
	 */
	private static String user = "julien.tendero";
	/**
	 * Mot de passe du user
	 */
	private static String passwd = "oracle";
	
	
	/**
	 * Objet Connection
	 */
	private static Connection connect;

	/**
	 * Méthode qui va nous retourner notre instance
	 * et la créer si elle n'existe pas...
	 * @return
	 */
	public static Connection getInstance(){
		if(connect == null){
			System.out.println("debut connexion");
	        try {

	        	Class.forName("oracle.jdbc.driver.OracleDriver");
				
	            System.out.println("DRIVER OK ! ");

	            String url = "jdbc:oracle:thin:@v240.ig.polytech.univ-montp2.fr:1521:ORA10";
		    String user = "julien.tendero";
		    String passwd = "oracle";

		    connect = DriverManager.getConnection(url, user, passwd);
		    System.out.println("Connection effective !!!!!!!!");
			} catch (SQLException e) {
				e.printStackTrace();
			}catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
		}
		}
		return connect;
	}




}


